package com.example.demo.zaqizabatest;

import com.example.demo.test1.entity.Test1;

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author lys4134
 * @ClassName Test111
 * @Date 2022/03/12 10:08:34
 * @Description Test111
 * @Version 1.0
 **/
public class Test111 {

    // 测试
    public static void main(String[] args) throws IOException {
        String test = "Last login: Fri Sep  2 14:43:20 2022 from 10.10.6.62\n" +
                "\n" +
                "[root@phy-10-1-206-134 ~]# kubectl exec -it zt-raft-0-1191 -- bash \n" +
                "Defaulted container \"zt-raft-0-1191\" out of: zt-raft-0-1191, chown-auth (init)\n" +
                " exit \n" +
                "\u001B[?1034hbash-4.2$ top -b -n 1 | grep 'load average:' | awk '{split($0, array, \"load aver \n" +
                "age: \");print array[2]}'| awk '{split($0, array, \",\");print array[1]}'\n" +
                "5.02\n" +
                "bash-4.2$ exit";
        String testString = "$ top -b -n 1 | grep 'load average:' | awk '{split($0, array, \"load average: \");print array[2]}'| awk '{split($0, array, \",\");print array[1]}'";




        boolean contains = test.contains(testString);

        //测试
        Pattern p= Pattern.compile("[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*");

        String str = "abc+%";
        Matcher m = p.matcher(str);
        System.out.println(m.matches());

//        ArrayList<Test1> list1 = new ArrayList<>();
//        Test1 test1 = new Test1(1, "aa", "a", new Date());
//        Test1 test2 = new Test1(2, "bb", "b", new Date());
//        Test1 test3 = new Test1(3, "cc", "c", new Date());
//        list1.add(test1);
//        list1.add(test2);
//        list1.add(test3);
//        ArrayList<Test1> list2 = new ArrayList<>();
//        Test1 test11 = new Test1(1, "a1", "a1", new Date());
//        Test1 test22 = new Test1(2, "b1", "b1", new Date());
//        Test1 test33 = new Test1(3, "c1", "c1", new Date());
//        list2.add(test11);
//        list2.add(test22);
//        list2.add(test33);
//        System.out.println(list1.contains(test11));
//        System.out.println(list1.containsAll(list2));
//        Collections.sort(list1);
//        System.out.println(list1);
//        list1.stream().forEach(item -> Optional.of(test2).isPresent());
//
//
//        Comparator<Test1> comparator = (o1, o2) -> o2.getFirst().compareTo(o1.getFirst());
//        Collections.sort(list2, comparator);
//        System.out.println(list2);
//        List<String> collect = list1.stream().map(Test1::getFirst).collect(Collectors.toList());
//        List<String> collect1 = list1.stream().flatMap(s -> Arrays.stream(s.getFirst().split(""))).collect(Collectors.toList());
//        System.out.println(collect);
//        System.out.println(collect1);
//        Optional<String> optional = Optional.ofNullable(test1).map(Test1::getFirst);
//        System.out.println(optional.get());
//        BufferedReader reader = new BufferedReader(new FileReader(new File("")));
//        String line = null;
//        while ((line = reader.readLine()) != null) {
//            System.out.println(line);
//        }
    }

}
